
clear all
capture log close
set more off

/* Insert your own pathname here */
cd "/Users/joshlewis/Dropbox/Clay_Lewis_Severnini_2018JEH/"

log using "Clay_Lewis_Severnini_Replication.log", replace

use "Clay_Lewis_Severnini_2018JEH_data.dta", clear




***********
*Globals
***********

*Controls
global geog "xtrend ytrend xXd18 yXd18"
global demog "poptrend swhitetrend pctforeigntrend pcturbtrend popXd18 swhiteXd18 pctforeignXd18 pcturbXd18"
global econ "i.year*tercile_home mfgtrend mfgwagetrend mfgXd18 mfgwageXd18"

*Terciles
global tercile1 "tercile1Xd18 tercile1Xd19 tercile1Xd20 tercile1Xd21 tercile1Xd22 tercile1Xd23 tercile1Xd24 tercile1Xd25"
global tercile2 "tercile2Xd18 tercile2Xd19 tercile2Xd20 tercile2Xd21 tercile2Xd22 tercile2Xd23 tercile2Xd24 tercile2Xd25"





****************************************
****************************************
****************************************
****************************************
*Tables
****************************************
****************************************
****************************************
****************************************



****************************************
*Table 1: Summary statistics
****************************************

*Sample means


su infmort_rate mort_rate imr_diff1715 mr_diff1715 imr_diff2515 mr_diff2515 rlinfmort18 rlmort18   /*
*/ steammw_30mile hydromw_30mile lpopdensity pcturb1910 swhite1910 pctforeign1910 pctmanuf1910 mwagep tercile_home typhoidave late distance


*Unadjusted differences & Propensity score adjusted differences

*Order-probit propensity score
oprobit tercilegrp lpop1921 swhite1910 pctforeign1910 pcturb1910 lmfg1910 lmwage1900 tercile_home 
predict pscore, p


reg infmort_rate  tercile1 tercile2 point_x point_y  , cluster(citycode)
outreg2 tercile1 tercile2 using "tables/Table1.xls", nocons bracket e(N_clust) replace

foreach var of varlist infmort_rate mort_rate imr_diff1715 mr_diff1715 imr_diff2515 mr_diff2515 rlinfmort18 rlmort18   /*
*/ steammw_30mile hydromw_30mile lpopdensity pcturb1910 swhite1910 pctforeign1910 pctmanuf1910 mwagep tercile_home typhoidave late distance { 

reg `var'  tercile1 tercile2 point_x point_y  , cluster(citycode)
outreg2 tercile1 tercile2 using "tables/Table1.xls", nocons bracket e(N_clust) append

reg `var'  tercile1 tercile2 point_x point_y pscore  , cluster(citycode)
outreg2 tercile1 tercile2 using "tables/Table1.xls", nocons bracket e(N_clust) append

}




****************************************
*Table 2: Effects of coal-fired capacity on pandemic mortality
****************************************

*Infant mortality
xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table2.xls", nocons bracket e(N_clust) replace

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table2.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table2.xls", nocons bracket e(N_clust) append

*ALl-age mortality
xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table2.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table2.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table2.xls", nocons bracket e(N_clust) append






****************************************
*Table 4: Other determinants of pandemic severity
****************************************

*Infant mortality
global demog1 "poptrend pcturbtrend popXd18 pcturbXd18"

xi: areg linfmort i.year $geog $demog1 $econ $tercile1 $tercile2 ltyptrend ltypXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 ltypXd18 using "tables/Table4.xls", nocons bracket e(N_clust) replace

xi: areg linfmort i.year $geog $demog1 $econ $tercile1 $tercile2 swhitetrend pctforeigntrend swhiteXd18 pctforeignXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 swhiteXd18 pctforeignXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $demog $econ $tercile1 $tercile2 latetrend lateXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 lateXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $demog $econ $tercile1 $tercile2 nearww1trend nearww1Xd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 lateXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append


xi: areg linfmort i.year $demog1 $econ $tercile1 $tercile2 ltyptrend ltypXd18 swhitetrend pctforeigntrend swhiteXd18 pctforeignXd18 latetrend lateXd18 nearww1trend nearww1Xd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 ltypXd18 swhiteXd18 pctforeignXd18 lateXd18 nearww1Xd18 using "tables/Table4.xls", nocons bracket e(N_clust) append


*All-age mortality
xi: areg lmort i.year $geog $demog1 $econ $tercile1 $tercile2 ltyptrend ltypXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 ltypXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year $geog $demog1 $econ $tercile1 $tercile2 swhitetrend pctforeigntrend swhiteXd18 pctforeignXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 swhiteXd18 pctforeignXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $demog $econ $tercile1 $tercile2 latetrend lateXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 lateXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $demog $econ $tercile1 $tercile2 nearww1trend nearww1Xd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 lateXd18 using "tables/Table4.xls", nocons bracket e(N_clust) append


xi: areg lmort i.year $demog1 $econ $tercile1 $tercile2 ltyptrend ltypXd18 swhitetrend pctforeigntrend swhiteXd18 pctforeignXd18 latetrend lateXd18 nearww1trend nearww1Xd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 ltypXd18 swhiteXd18 pctforeignXd18 lateXd18 nearww1Xd18 using "tables/Table4.xls", nocons bracket e(N_clust) append


****************************************
*Table 5: Local interventions
****************************************

*Infant mortality

xi: areg linfmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table5.xls", nocons bracket e(N_clust) replace

xi: areg linfmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 if  markelsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table5.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 earlyrespXd18 if  markelsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 earlyrespXd18 using "tables/Table5.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 longintXd18 if  markelsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 longintXd18 using "tables/Table5.xls", nocons bracket e(N_clust) append




*All-age mortality
xi: areg lmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table5.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 if  markelsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table5.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 earlyrespXd18 if  markelsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 earlyrespXd18 using "tables/Table5.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year xtrend ytrend xXd18 yXd18 poptrend popXd18 tercile1Xd18 tercile2Xd18 longintXd18 if  markelsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 longintXd18 using "tables/Table5.xls", nocons bracket e(N_clust) append






****************************************
*Table 6: Robustness -- Alternative measures of infant mortality
****************************************


xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table6.xls", nocons bracket e(N_clust) replace

xi: areg linfmort_v1 i.year xtrend ytrend xXd18 yXd18 i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2  , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table6.xls", nocons bracket e(N_clust) append

xi: areg linfmort_v2 i.year xtrend ytrend xXd18 yXd18 i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table6.xls", nocons bracket e(N_clust) append



****************************************
*Table 7: Robustness
****************************************
global demog1 "lpopdensitytrend swhitetrend pctforeigntrend pcturbtrend lpopdensityXd18 swhiteXd18 pctforeignXd18 pcturbXd18"
global tercile1wind "tercile1Xd18lwind tercile1Xd18hwind tercile1Xd19 tercile1Xd20 tercile1Xd21 tercile1Xd22 tercile1Xd23 tercile1Xd24 tercile1Xd25"
global tercile2wind "tercile2Xd18lwind tercile2Xd18hwind tercile2Xd19 tercile2Xd20 tercile2Xd21 tercile2Xd22 tercile2Xd23 tercile2Xd24 tercile2Xd25"



*Infant mortality
xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) replace

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 i.state*year $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog1 $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 frac1844Xd18 frac1844trend $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg infmort_rate i.year i.year*infmort15 i.year*infmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 if balancedsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 if south==0, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 if pop1921>=50000, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1wind $tercile2wind , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18lwind tercile1Xd18hwind tercile2Xd18lwind tercile2Xd18hwind using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 tercile1hydroXd18 tercile2hydroXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile1hydroXd18 tercile2Xd18 tercile2hydroXd18 using "tables/Table7.xls", nocons bracket e(N_clust) append


*All-age mortality
xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 i.state*year $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog1 $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 frac1844Xd18 frac1844trend $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg mort_rate i.year i.year*mortrate15 i.year*mortrate16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 if balancedsample==1, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 if south==0, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 if pop1921>=50000, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile2Xd18 using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1wind $tercile2wind , abs(citycode) cluster(citycode)
outreg2 tercile1Xd18lwind tercile1Xd18hwind tercile2Xd18lwind tercile2Xd18hwind using "tables/Table7.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 tercile1hydroXd18 tercile2hydroXd18, abs(citycode) cluster(citycode)
outreg2 tercile1Xd18 tercile1hydroXd18 tercile2Xd18 tercile2hydroXd18 using "tables/Table7.xls", nocons bracket e(N_clust) append


****************************************
****************************************
****************************************
****************************************
*Figures
****************************************
****************************************
****************************************
****************************************


****************************************
*Figure 2
****************************************

xi, noomit: reg infmort_rate i.year, nocons
outreg2 using "tables/Figure2.xls", stats(coef) noast  replace

xi, noomit: reg mort_rate i.year, nocons
outreg2 using "tables/Figure2.xls", stats(coef) noast  append


****************************************
*Figure 3
****************************************
*Terciles
global tercile1a "tercile1Xd15 tercile1Xd16 tercile1Xd18 tercile1Xd19 tercile1Xd20 tercile1Xd21 tercile1Xd22 tercile1Xd23 tercile1Xd24 tercile1Xd25"
global tercile2a "tercile2Xd15 tercile2Xd16 tercile2Xd18 tercile2Xd19 tercile2Xd20 tercile2Xd21 tercile2Xd22 tercile2Xd23 tercile2Xd24 tercile2Xd25"



*Infant mortality
xi: areg linfmort i.year xtrend ytrend xXd18 yXd18 $tercile1a $tercile2a , abs(citycode) cluster(citycode)
outreg2 $tercile1a $tercile2a using "tables/Figure3.xls", nocons bracket e(N_clust) replace

xi: areg linfmort i.year i.year*linfmort15 i.year*linfmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 $tercile1 $tercile2 using "tables/Figure3.xls", nocons bracket e(N_clust) append

*All age mortality
xi: areg lmort i.year xtrend ytrend xXd18 yXd18 $tercile1a $tercile2a , abs(citycode) cluster(citycode)
outreg2 $tercile1a $tercile2a using "tables/Figure3.xls", nocons bracket e(N_clust) append

xi: areg lmort i.year i.year*lmort15 i.year*lmort16 $geog $demog $econ $tercile1 $tercile2 , abs(citycode) cluster(citycode)
outreg2 $tercile1 $tercile2 using "tables/Figure3.xls", nocons bracket e(N_clust) append



cap log close




















